#include "rpc_server/Rpc_server.hpp"
#include "cal_common/Log.hpp"
#include "cal_common/Util.hpp"
#include "cal_common/calculate.hpp"

int main()
{
    wuzi wz;
    std::unique_ptr<Rpc::Server::SDescribeFactory> desc_factory_check_win_wuzi(new Rpc::Server::SDescribeFactory());
    desc_factory_check_win_wuzi->setMethodName("wuzi_win");
    desc_factory_check_win_wuzi->setParamsDesc("board_info", Rpc::Server::VType::OBJECT);
    desc_factory_check_win_wuzi->setParamsDesc("row", Rpc::Server::VType::INTEGRAL);
    desc_factory_check_win_wuzi->setParamsDesc("col", Rpc::Server::VType::INTEGRAL);
    desc_factory_check_win_wuzi->setParamsDesc("color", Rpc::Server::VType::INTEGRAL);
    desc_factory_check_win_wuzi->setParamsDesc("white_id", Rpc::Server::VType::INTEGRAL);
    desc_factory_check_win_wuzi->setParamsDesc("black_id", Rpc::Server::VType::INTEGRAL);
    desc_factory_check_win_wuzi->setReturnType(Rpc::Server::VType::OBJECT);
    desc_factory_check_win_wuzi->setCallback(std::bind(&wuzi::check_win, &wz, std::placeholders::_1, std::placeholders::_2));

    std::unique_ptr<Rpc::Server::SDescribeFactory> desc_factory_ai_wuzi(new Rpc::Server::SDescribeFactory());
    desc_factory_ai_wuzi->setMethodName("ai_wuzi");
    desc_factory_ai_wuzi->setParamsDesc("board_info", Rpc::Server::VType::OBJECT);
    desc_factory_ai_wuzi->setParamsDesc("color", Rpc::Server::VType::INTEGRAL);
    desc_factory_ai_wuzi->setReturnType(Rpc::Server::VType::OBJECT);
    desc_factory_ai_wuzi->setCallback(std::bind(&wuzi::ai_gobang, &wz, std::placeholders::_1, std::placeholders::_2));

    Rpc::Server::RpcServer server(Rpc::Address("8.153.171.255", 31210), true, Rpc::Address("118.193.33.170", 31218));
    server.registerMethod(desc_factory_check_win_wuzi->build());
    server.registerMethod(desc_factory_ai_wuzi->build());
    server.start();
    return 0;
}
